<!doctype html>
<html>
<head>
    <title>分类添加</title>
    <?php $this->load->module('admin/index/page_header');?>
</head>
<body>
<div class="wrap">
    <div class="table_list">
        <form action="" method="post" class="formvalidate">
        <table width="100%">
            <thead>
                <tr>
                    <td width="45">删除</td>
                    <td width="30%">分类名称</td>
                    <td>描述</td>
                    <td width="100">攻略数目</td>
                </tr>
            </thead>
            <tbody>
            <?php foreach ($list as $v) { ?>
                <tr>
                    <td><input type="checkbox" class="checkbox" name="delete[]" value="<?php echo $v['id']?>" /></td>
                    <td class="add-sub">
                        <?php if($v['parent_id']){echo '&nbsp;&nbsp;&nbsp;&nbsp;└─&nbsp;';}?>
                        <span data-title="name[<?php echo $v['id']?>]"><?php echo $v['name']?></span>
                        <?php if($v['parent_id'] ==0):?>
                            &nbsp;<a title="添加子分类" style="display:none" class="add" onclick="addrowdirect = 1;addrow(this, 1, <?php echo $v['id']?>);">子分类</a>
                        <?php endif;?>
                        <a class="layer" href="<?php echo site_url('trips/admin/category_edit/?id='.$v['id']);?>" style="display:none">编辑</a>
                    </td>
                    <td><span data-title="description[<?php echo $v['id']?>]"><?php echo $v['description'] ? $v['description'] : '-'?></span></td>
                    <td><?php echo $v['trips_count']?>篇</td>
                </tr>
            <?php }?>
                <tr>
                    <td>&nbsp;</td>
                    <td colspan="3"><a class="add" href="javascript:void(0);" onclick="addrow(this, 0)">添加分类</a></td>
                </tr>
                <tr>
                    <td>&nbsp;</td>
                    <td colspan="3">
                        <button type="submit" class="btn btn_submit J_ajax_submit_btn">提交</button>
                    </td>
                </tr>
            </tbody>
        </table>
        </form>
    </div>
</div>
<script type="text/javascript">
    var rowtypedata = [
        [
            [1, '&nbsp;'],
            [1, '<input class="input" type="text" size="30" name="new_category[{n}][n]" />'],
            [1, '<input class="input" type="text" size="70" name="new_category[{n}][d]" /> <a href="javascript:void(0);" class="del" onclick="deleterow(this)">删除</a>'],
            [1, '0篇']
        ],
        [
            [1, '&nbsp;'],
            [1, '&nbsp;&nbsp;&nbsp;&nbsp;└─&nbsp;<input class="input" type="text" size="30" name="new_sub_category[{1}][n][]" />'],
            [1, '<input class="input" type="text" size="70" name="new_sub_category[{1}][d][]" /> <a href="javascript:void(0);" class="del" onclick="deleterow(this)">删除</a>'],
            [1, '0篇']
        ]
    ];


</script>
<script type="text/javascript">
$(function(){
    $('.add-sub').hover(function(){
        $(this).find('a').show();
    }, function(){
        $(this).find('a').hide();
    });
});
</script>
</body>
</html>